import Mock from "mockjs";
import qs from "querystring"
Mock.mock('/api/message', 'post', {
    code: 0,
    msg: '',
    data: {
        id: "@guid",
        nickname: '@cname',
        content: '@cparagraph(1,10)',
        createDate: Date.now(),
        "avatar|1": [
            "https://qiheizhiya.oss-cn-shenzhen.aliyuncs.com/image/avatar6.jpg",
            "https://qiheizhiya.oss-cn-shenzhen.aliyuncs.com/image/avatar4.jpg",
            "https://qiheizhiya.oss-cn-shenzhen.aliyuncs.com/image/avatar8.jpg",
            "https://qiheizhiya.oss-cn-shenzhen.aliyuncs.com/image/avatar2.jpg",
        ],
    }
});
Mock.mock(/^\/api\/message\/?(\?.+)?$/, 'get', function(options) {
    const url = qs.parse(options.url);
    //  console.log(url)
    return Mock.mock({
        code: 0,
        msg: '',
        data: {
            total: 52,
            [`rows|${url.limit ||10}`]: [{
                //在对象里面属性名是一个表达式就需要用中括号包一下
                id: "@guid", //guid是出现一串唯一的字符串
                nickname: '@cname',
                content: '@cparagraph(1,10)',
                createDate: Date.now(),
                "avatar|1": [
                    "https://qiheizhiya.oss-cn-shenzhen.aliyuncs.com/image/avatar6.jpg",
                    "https://qiheizhiya.oss-cn-shenzhen.aliyuncs.com/image/avatar4.jpg",
                    "https://qiheizhiya.oss-cn-shenzhen.aliyuncs.com/image/avatar8.jpg",
                    "https://qiheizhiya.oss-cn-shenzhen.aliyuncs.com/image/avatar2.jpg",
                ],
                //img的size中间必须是x不能是*，
            }]
        }



    })
});